var teamId;
var teamName;
var tmTeamPlace;
var teamGameList;
$(document).ready(function(){	
	$('#header').animate({'top':'0px'},400);
	teamId = args.teamId; //取得id的值
	teamName = args.teamName;
	//$("#teamName").text(teamName);
	
	$.getJSON(path+"/soccer/teamAction!selectInActiveGameByTeam.action",{teamId: teamId}, function(data){
//	  	  debugger;
		  teamGameList = data.teamGameList;
	  	  var teamGameHtml=[];
	  	  $.each(teamGameList,function(index,obj){//debugger;
	  		  
	  		  if(index%2==0){
	  			teamGameHtml.push("<div class='portfolio_item' style='background:#00CC00;margin:10px 2%;padding:10px 2%;'>");
	  			
	  		  }else{
	  			teamGameHtml.push("<div class='portfolio_item' style='background:#00CCFF;margin:10px 2%;padding:10px 2%;'>");
	  		  }
	  		  //teamGameHtml.push("<div class='service_box'>");
	  		  //teamGameHtml.push("<div class='service_content'>");
	  		  teamGameHtml.push("<h4 style='color:red'>"+moment(obj.gameDate,"YYYY-MM-DD").format("MM月DD日")+" "+obj.gameName+"</h4><h5 style='color:red'>比分&nbsp&nbsp"+obj.ourScore+":"+obj.oppScore+"</h5>");
	  		  teamGameHtml.push("<p>时间："+moment(obj.gameDate,"YYYY-MM-DD").format("YYYY年MM月DD日")+" "+moment(obj.startTime,"YYYY-MM-DD HH:mm:ss").format("HH:mm")+"~"+moment(obj.endTime,"YYYY-MM-DD HH:mm:ss").format("HH:mm")+"</p>");
	  		  teamGameHtml.push("<p><strong>要求到场时间："+moment(obj.arriveTime,"YYYY-MM-DD HH:mm:ss").format("HH:mm")+"</strong>&nbsp");
	  		  teamGameHtml.push("<div style='font-size:30px;color:red;text-align:center;position:absolute;right:20%;margin-top:-50px;margin-right:-40px;'><p href='#' onclick='viewSignup("+obj.teamId+","+obj.rowId+")'>"+obj.bmrs+"/"+obj.signupNum+"</p><p style='font-size:15px;color:red;'>人报名</p></div></p>");
	  		  teamGameHtml.push("<p>地点："+obj.placeName+"</p>");
	  		  teamGameHtml.push("<p>性质："+GAME_TYPE_ARRAY[obj.gameType]+"</p>");
	  		  teamGameHtml.push("<p>对手："+obj.opponentName+"</p>");
	  		  if(obj.statusFlag=="30"||obj.statusFlag=="ZZ"){
		  	    teamGameHtml.push("<a href='#' onclick='viewGameScore("+obj.teamId+","+obj.rowId+")' class='button_12 yellow'>查看全体得分</a>");
		  	  }
	  		  
	  		  teamGameHtml.push("</div>");
	  		//teamHtml.push("<tr class='info'><td>"+obj.taskDetail+"</td><td>"+obj.sendUserName+"</td><td>"+moment(obj.sendTime,"YYYY-MM-DD HH:mm:ss").format("YYYY-MM-DD HH:mm:ss")+"</td></tr>");
	  	   });
	  	   $("#teamGameList").html(teamGameHtml.join(""));  
	  		  //alert(data);
	});
	
});
function goBack(){
	window.location.href=path+"/soccer/teamMain.jsp?teamId="+teamId+"&teamName="+teamName;
}

function viewSignup(teamId,tmGameId){
	var timestamp = (new Date()).valueOf();
	var backURL="/soccer/teamGameInactive.jsp";
	window.location.href=path+"/soccer/teamGameSignupView.jsp?teamId="+teamId+"&teamName="+teamName+"&tmGameId="+tmGameId+"&backURL="+backURL+"&timestamp="+timestamp;
}

function viewGameActive(){
	var timestamp = (new Date()).valueOf();
	window.location.href=path+"/soccer/teamGame.jsp?teamId="+teamId+"&teamName="+teamName+"&timestamp="+timestamp;
}

function viewGameScore(teamId,tmGameId){
	var timestamp = (new Date()).valueOf();
	var backURL="/soccer/teamGameInactive.jsp";
	sessionStorage.setItem("teamGameDataSet-backURL", "/soccer/teamGameInactive.jsp");
	//window.location.href=path+"/soccer/teamGameScoreView.jsp?teamId="+teamId+"&teamName="+teamName+"&tmGameId="+tmGameId+"&backURL="+backURL+"&timestamp="+timestamp;
	window.location.href=path+"/soccer/teamGameDataSet-techScore.jsp?teamId="+teamId+"&teamName="+teamName+"&tmGameId="+tmGameId+"&backURL="+backURL+"&timestamp="+timestamp;
}



